// Rust have import std::prelude by default
// io library is not in std::prelude
// so we have to import by 'use'
use std::io;

// fn main is the entry of rust
// it didn't include a return type
// it's assumed to be (), an empty tuple
fn main() {
    println!("Guess the number!");

    println!("Please input your guess.");

    // Variable binding
    // let doesn’t take a name on the left hand side 
    // it actually accepts a ‘pattern’
    // String is provided by standard library, it is growable
    // '::' is an 'associated function'(static method) of a particular type
    let mut guess = String::new();

    // if didn't 'use std::io', wo have to use std::io.stdin()
    // this fn return a std::io.Stdin handle the standard input
    // reference is immutable by default, so we need &mut guess
    // read_line return an io::Result, it is for error handle

    io::stdin().read_line(&mut guess)
        .ok()
        .expect("Failed to read line");

    // '{}' is a placeholder
    println!("You guessed: {}", guess);
}